package com.jerry.spring.security.jwt.domain;

import lombok.Data;

/**
 * 公共响应体
 *
 * @author jerry 2024/5/8 15:21
 */
@Data
public class ResponseResult<T> {

    private Integer code;

    private String message;

    private T data;

    public static <T> ResponseResult<T> ok() {
        ResponseResult<T> result = new ResponseResult<>();
        result.setCode(0);
        result.setMessage("成功");
        return result;
    }

    public static <T> ResponseResult<T> ok(T t) {
        ResponseResult<T> result = new ResponseResult<>();
        result.setCode(0);
        result.setMessage("成功");
        result.setData(t);
        return result;
    }

    public static <T> ResponseResult<T> error(String message) {
        ResponseResult<T> result = new ResponseResult<>();
        result.setCode(1);
        result.setMessage(message);
        return result;
    }

}
